﻿namespace Lottery.Model
{
    public class GroupRule
    {

        private string company;
        private string dept;
        private string giftLevelName;
        private int ruleNumber;
        private int lostNumber;

        public string Company
        {
            get => company; set
            {
                if (string.IsNullOrEmpty(value))
                    company = value;
                else
                    company = value.Trim().ToUpper();
            }
        }
        public string Dept
        {
            get { return dept; }
            set
            {
                if (string.IsNullOrEmpty(value))
                    dept = value;
                else
                    dept = value.Trim().ToUpper();
            }
        }

        public int RuleNumber { get => ruleNumber; set => ruleNumber = value; }
        public int LostNumber { get => lostNumber; set => lostNumber = value; }
        public string GiftLevelName
        {
            get => giftLevelName; set
            {
                if (string.IsNullOrEmpty(value))
                    giftLevelName = value;
                else
                    giftLevelName = value.Trim().ToUpper();
            }
        }


        public bool match(string incompany, string indept)
        {
            int rest = 2;
            if (string.IsNullOrEmpty(this.company))
            {
                rest--;
            }
            else
            {
                if (this.company.Equals(incompany))
                {
                    rest--;
                }
            }
            if (string.IsNullOrEmpty(this.dept))
            {
                rest--;
            }
            else
            {
                if (this.dept.Equals(indept))
                {
                    rest--;
                }
            }

            return rest <= 0;

        }
    }
}
